<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文字内容逐渐显示</title>
</head>
<body>
<div id="app">
    <div id="show" v-bind:style="{opacity}">双十一购物街快乐</div>
</div>

<script src="../../../../js/vue.global.js"></script>
<script>
    const app = Vue.createApp({
        data() {
            return {
                opacity: 1
            }
        },

        mounted() {
            console.log("调用了 mounted ");
            console.log(this);

            let that = this
            setInterval(function () {
                // console.log(this);
                console.log(that);
                that.opacity += 0.02
                console.log(that.opacity);
                if (that.opacity > 1) {
                    that.opacity = 0
                }
            }, 500)

            /*setInterval( ()  =>{
                this.opacity += 0.02
                console.log(this.opacity);
                if (this.opacity > 1) {
                    this.opacity = 0
                }
            }, 50)*/
        }
    })
    app.mount("#app")
</script>
</body>
</html>